{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>

            <script type="text/html" id="imgTpl">
                {{#  if(d.logo){ }}
                <a href="{{ d.logo }}" target="_blank">
                    <img style="display: inline-block; height: 100%;" src={{ d.logo }}>
                </a>
                {{# } }}
            </script>
            <script type="text/html" id="sTpl">
                {{#  if(d.status==1){ }}
                审核通过
                {{# } }}
                {{#  if(d.status==2){ }}
                审核不通过
                {{# } }}
                {{#  if(d.status==0){ }}
                审核中
                {{# } }}
            </script>
            <script type="text/html" id="codeTpl">
                {{#  if(d.code){ }}
                <a href="{{ d.code }}" target="_blank">
                    <img style="display: inline-block; height: 100%;" src="{{ d.code }}">
                </a>
                {{# } }}
            </script>
            <script type="text/html" id="table-type">
                <div>{{d.rule.typename}}</div>
            </script>
            <script type="text/html" id="table-useradmin-webuser">
                <a class="layui-btn layui-btn-normal layui-btn-xs" url="/menu/add" lay-event="info">编辑</a>
                <a class="layui-btn layui-btn-normal layui-btn-xs" url="/menu/add" lay-event="read">积分</a>
            </script>
        </div>
    </div>
</div>
<script>
    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;

        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('LAY-user-manage', {
                where: field
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        //用户管理
        table.render({
            elem: '#LAY-user-manage'
            , url: "{:url('Fleet/ajaxShop')}" //模拟接口
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', width: 100, title: 'ID', sort: true, align: 'center'}
                , {field: 'name', title: '用户名', minWidth: 100, align: 'center'}
                , {field: 'nick_name', title: '合作商名称', minWidth: 100, align: 'center'}
                , {field: 'mobile', title: '联系方式', minWidth: 100, align: 'center'}
                , {field: 'integral', title: '积分', minWidth: 100, align: 'center'}
                , {field: 'logo', title: '合作商LOGO', minWidth: 100, align: 'center',toolbar:'#imgTpl'}
                , {field: 'code', title: '二维码', minWidth: 100, align: 'center',toolbar:'#codeTpl'}
                , {field: 'status', title: '状态', align: 'center',toolbar:'#sTpl'}
                , {field: 'create_time', title: '添加时间', sort: true , align: 'center'}
                , {title: '操作', width: 250, align: 'center', fixed: 'right', toolbar: '#table-useradmin-webuser', align: 'center'}
            ]]
            , page: false
            , limit: 30
            , height: 'full-50'
            , text: '对不起，加载出现异常！'
        });


        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            var url = "";
            if (type == 'add') {
                url = "{:url('Fleet/add')}";
            }
            active[type] ? active[type].call(this, url, table) : '';
        });
    });
</script>
</body>
</html>
{/block}
